home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / cubezip.exe / CUBESYS.INC < prev    next >
Text File  |  1991-10-15  |  24KB  |  706 lines

  1. ;┌──────────────────────────────────────────────────────────────────────────┐
  2. ;│             CUBESYS.INC - Include file for the Cube Solver            │
  3. ;└──────────────────────────────────────────────────────────────────────────┘
  4. BRIGHT_ON_BLACK        equ    0Fh
  5. CYAN_ON_BLUE        equ    13h
  6. MAGENTA_ON_BLUE        equ    15h
  7. BRIGHT_ON_BLUE        equ    1Fh
  8. BRIGHT_ON_MAGENTA    equ    5Fh
  9. DIM_ON_MAGENTA        equ    57h
  10.  
  11. ;────────────────────────────────────────────────────────────────────────────
  12. LINE_LENGTH        equ    80    ; chars
  13. LINE_COUNT        equ    25    ; lines
  14.  
  15. ;────────────────────────────────────────────────────────────────────────────
  16. STACK_DEPTH        equ    512
  17.  
  18. ;────────────────────────────────────────────────────────────────────────────
  19. InvocationCursor    dw    ?    ; the caller's initial cursor loc.
  20. ScreenSegment        dw    0B800h    ; our default display seg
  21. ExitingMessage        dw    OFFSET NormalTermination
  22. OldTimerVector        dd    ?
  23. Count1            dw    0
  24. Count2            dw    0
  25. TickCount1        dw    0
  26. TickCount2        dw    0
  27. SingleStepping        db    TRUE
  28. Animation        db    TRUE
  29. Sound            db    FALSE
  30. PausePoint        dw    00FEh        ; no pause code
  31.  
  32. ;────────────────────────────────────────────────────────────────────────────
  33. Period            dw    0    ; Sound system symbols
  34. DeltaFreq        dw    0
  35. Duration        dw    0
  36. PhasorPosition        dw    0
  37.  
  38. ;────────────────────────────────────────────────────────────────────────────
  39. ColorChart    db     3 dup (MAGENTA_ON_BLUE)
  40.         db     2 dup (BRIGHT_ON_BLUE)
  41.         db    13 dup (CYAN_ON_BLUE)
  42.         db     2 dup (BRIGHT_ON_BLUE)
  43.         db     5 dup (MAGENTA_ON_BLUE)
  44.  
  45. ;────────────────────────────────────────────────────────────────────────────
  46. ScreenOffset    dw    (6*80+ 3)*2, (6*80+10)*2, (6*80+17)*2, (6*80+24)*2
  47.         dw    (6*80+31)*2, (6*80+38)*2, (6*80+45)*2, (6*80+52)*2
  48.         dw    (6*80+59)*2
  49.  
  50. ;────────────────────────────────────────────────────────────────────────────
  51. NumericsPosition   dw    (18*80+ 6)*2,(18*80+13)*2,(18*80+20)*2,(18*80+27)*2
  52.            dw    (18*80+34)*2,(18*80+41)*2,(18*80+48)*2,(18*80+55)*2
  53.            dw    (18*80+62)*2
  54.  
  55. ;────────────────────────────────────────────────────────────────────────────
  56. CharacterTable    dw    0B2B2h, 0, 020DBh, 0DCDCh, 0DFDFh, 0DB20h, 0, 0B0B0h
  57.  
  58.  
  59.  
  60. ;════════════════════════════════════════════════════════════════════════════
  61. SetupTheSystem:
  62. ;┌──────────────────────────────────────────────────────────────────────────┐
  63. ;│       Get everything up and running ...                    │
  64. ;└──────────────────────────────────────────────────────────────────────────┘
  65.         call    SaveScreenAndCursor
  66.         Hook    TIMER_INT, OldTimerVector, CountTicks
  67.         call    AllocateMemoryRegions
  68.         jmp    DisplayTheScreen    ; EXIT THROUGH ...
  69.  
  70. Exit:
  71. ;┌──────────────────────────────────────────────────────────────────────────┐
  72. ;│       Restore Timer vector, user's screen, and exit to DOS ...        │
  73. ;└──────────────────────────────────────────────────────────────────────────┘
  74.         mov    dx, WORD PTR OldTimerVector
  75.         mov    ds, WORD PTR OldTimerVector+2
  76.         mov    ax, DOS_SET_VECTOR*256 + TIMER_INT
  77.         int    DOS_FUNC
  78.         pupop    ds, cs        
  79. ;────────────────────────────────────────────────────────────────────────────
  80.         mov    cx, SCREEN_LENGTH / 2
  81.         mov    si, OFFSET InitScreenBuffer
  82.         zero    di
  83.         mov    es, ScreenSegment
  84.         rep movsw
  85. ;────────────────────────────────────────────────────────────────────────────
  86.         mov    ax, SET_CURSOR_POS*256
  87.         zero    bh            ; (screen page 0)
  88.         mov    dx, InvocationCursor
  89.         int    VIDEO_IO
  90. ;────────────────────────────────────────────────────────────────────────────
  91.         mov    dx, ExitingMessage    ; print the standard message
  92.         mov    ah, DOS_PRINTSTRING
  93.         int    DOS_FUNC
  94.         int    COM_TERMINATE
  95. ;****************************************************************************
  96.  
  97.  
  98. DisplayTheScreen:
  99. ;┌──────────────────────────────────────────────────────────────────────────┐
  100. ;│         Blast the thrasher's data screen into screen               │
  101. ;│         memory then fixup the colorizing attributes.            │
  102. ;└──────────────────────────────────────────────────────────────────────────┘
  103.         zero    bx            ; init the line counter
  104.         mov    si, OFFSET ScreenDisplay
  105.         zero    di
  106.         mov    es, ScreenSegment
  107. ;────────────────────────────────────────────────────────────────────────────
  108. MoveALine:    mov    ah, ColorChart[bx]
  109.         mov    cx, LINE_LENGTH
  110. MoveIt:        lodsb
  111.         stosw
  112.         loop    MoveIt
  113.         inc    bx
  114.         cmp    bx, LINE_COUNT
  115.         jb    MoveALine
  116.  
  117.  
  118. ;┌──────────────────────────────────────────────────────────────────────────┐
  119. ;│                   Color the top and bottom text lines            │
  120. ;└──────────────────────────────────────────────────────────────────────────┘
  121.         mov    al, BRIGHT_ON_MAGENTA
  122.         mov    cx, 80-2
  123.         zero    di
  124. ;────────────────────────────────────────────────────────────────────────────
  125. WhiteWash:    mov    es:[di+( 1*80+1)*2+1], al
  126.         mov    es:[di+(21*80+1)*2+1], al
  127.         mov    es:[di+(22*80+1)*2+1], al
  128.         mov    es:[di+(23*80+1)*2+1], al
  129.         add    di, 2
  130.         loop    WhiteWash
  131. ;────────────────────────────────────────────────────────────────────────────
  132.         mov    di, (21*80+30)*2
  133.         call    ColorSix
  134.         mov    di, (21*80+60)*2
  135.         call    ColorSix
  136. ;────────────────────────────────────────────────────────────────────────────
  137.         call    PaintLowerRight
  138.  
  139. ;────────────────────────────────────────────────────────────────────────────
  140.         call    BlankEmAll
  141.         mov    di, (6*80+71)*2
  142.         call    BlankAtDI
  143. ;────────────────────────────────────────────────────────────────────────────
  144.         pupop    es, cs
  145.         jmp    RefreshScreen        ; return through ...
  146.  
  147.  
  148. BlankEmAll:
  149. ;╒══════════════════════════════════════════════════════════════════════════╕
  150. ;│              Blanks all of the piece regions                        │
  151. ;└──────────────────────────────────────────────────────────────────────────┘
  152.         push    bx
  153.         zero    bx
  154. BlankOne:    call    BlankCurrentPiece
  155.         add    bx, 2
  156.         cmp    bx, 9*2
  157.         jb    BlankOne
  158.         pop    bx
  159.         ret
  160.  
  161.  
  162. ColorSix:
  163. ;╒══════════════════════════════════════════════════════════════════════════╕
  164. ;│       Finishes coloring the display screen by dropping four colors        │
  165. ;└──────────────────────────────────────────────────────────────────────────┘
  166.         mov    ax, MAGENTA_ON_BLUE * 256 + " "
  167.         mov    cx, 3
  168. ColorTwo:    stosw
  169.         stosw
  170.         add    di, (80-2)*2
  171.         loop    ColorTwo
  172.         ret
  173.  
  174.  
  175. PaintLowerRight:
  176. ;╒══════════════════════════════════════════════════════════════════════════╕
  177. ;│    Re-Paints the lower right of the screen which was overcolored ...        │
  178. ;└──────────────────────────────────────────────────────────────────────────┘
  179.         mov    al, BRIGHT_ON_BLUE
  180.         mov    di, (20*80+62)*2+1
  181.         call    Paintshort
  182.         mov    al, MAGENTA_ON_BLUE
  183.         mov    di, (21*80+62)*2+1
  184. PaintShort:    mov    cx, 17
  185. PaintAttrib:    stosb
  186.         inc    di
  187.         loop    PaintAttrib
  188.         ret
  189.  
  190.  
  191. BlankCurrentPiece:
  192. ;╒══════════════════════════════════════════════════════════════════════════╕
  193. ;│               This routine blanks the current branch number            │
  194. ;└──────────────────────────────────────────────────────────────────────────┘
  195.         mov    di, ScreenOffset[bx]    ; get the upper left corner
  196. ;────────────────────────────────────────────────────────────────────────────
  197. BlankAtDI:    push    es
  198.         mov    es, ScreenSegment
  199.         bool    Animation
  200.         iffalse    BlankNumbers
  201. ;────────────────────────────────────────────────────────────────────────────
  202.         mov    cx, 3        ; we have three levels
  203. BlankOneLevel:    push    cx
  204.         mov    cx, 3        ; each level has three lines
  205. BlankOneLine:    push    cx
  206.         mov    ax, BRIGHT_ON_BLACK + " "
  207.         mov    cx, 6        ; each line has three blocks
  208.         rep stosw
  209. ;────────────────────────────────────────────────────────────────────────────
  210.         add    di, (80-6)*2        ; drop to next line
  211.         pop    cx
  212.         loop    BlankOneLine
  213. ;────────────────────────────────────────────────────────────────────────────
  214.         add    di, 160            ; skip one line
  215.         pop    cx
  216.         loop    BlankOneLevel
  217. ;────────────────────────────────────────────────────────────────────────────
  218. BlankNumbers:    mov    di, NumericsPosition[bx]
  219.         mov    BYTE PTR es:[di], " "
  220.         mov    BYTE PTR es:[di-2], " "
  221. ;────────────────────────────────────────────────────────────────────────────
  222.         pop    es
  223.         ret
  224.  
  225.  
  226.  
  227. ShowAllPieces:
  228. ;╒══════════════════════════════════════════════════════════════════════════╕
  229. ;│     This routine updates all the pieces.  It's called when the puzzle    │
  230. ;│     has been solved. most recently succesfully ...                │
  231. ;└──────────────────────────────────────────────────────────────────────────┘
  232.         call    BlankEmAll
  233.         push    bx
  234.         push    dx
  235.         mov    dx, bx
  236.         zero    bx
  237. ShowNextPiece:    call    GetPieceOffset
  238.         call    ShowItNow
  239.         add    bx, 2
  240.         cmp    bx, dx
  241.         jbe    ShowNextPiece
  242.         pop    dx
  243.         pop    bx
  244.         ret
  245.  
  246.  
  247. ShowCurrentPiece:
  248. ;╒══════════════════════════════════════════════════════════════════════════╕
  249. ;│     This routine shows the piece most recently succesfully ...        │
  250. ;│     Called with BX = CurrentPiece*2               (bx, dx, bp preserved) │
  251. ;└──────────────────────────────────────────────────────────────────────────┘
  252.         bool    Animation
  253.         iffalse    ShowNumbers
  254. ;────────────────────────────────────────────────────────────────────────────
  255. ShowItNow:    mov    di, ScreenOffset[bx]    ; get the upper left corner
  256.         mov    si, MergedPieceOffset
  257.         call    DisplayPiece
  258.         call    ShowCurrentPuzzle
  259. ShowNumbers:    jmp    ShowNumerics
  260.  
  261.  
  262. ShowCurrentPuzzle:
  263. ;╒══════════════════════════════════════════════════════════════════════════╕
  264. ;│     This routine shows the current pieces placed ino the puzzle ...        │
  265. ;│                                                   (bx, dx, bp preserved) │
  266. ;└──────────────────────────────────────────────────────────────────────────┘
  267.         mov    di, (6*80+71)*2
  268.         mov    si, bp
  269.  
  270. DisplayPiece:
  271. ;┌──────────────────────────────────────────────────────────────────────────┐
  272. ;│  This routine displays a 27-byte piece data-structure at screen loc DI.  │
  273. ;└──────────────────────────────────────────────────────────────────────────┘
  274.         push    bx
  275.         push    es
  276.         mov    es, ScreenSegment
  277.  
  278. ;────────────────────────────────────────────────────────────────────────────
  279.         mov    cx, 3        ; we have three levels
  280. CvrtOneLevel:    push    cx
  281.         mov    cx, 3        ; each level has three lines
  282. CvrtOneLine:    push    cx
  283.         mov    cx, 3        ; each line has three blocks
  284. CvrtOneBlock:    lodsb            ; get the next byte
  285.         cmp    al, 0
  286.         jne    NotEmpty
  287.         mov    bx, 02020h
  288.         jmp    Stuffit
  289. ;────────────────────────────────────────────────────────────────────────────
  290. NotEmpty:    cmp    al, 0FFh
  291.         jne    NotFull
  292.         mov    bx, 0DBDBh
  293.         jmp    Stuffit
  294. ;────────────────────────────────────────────────────────────────────────────
  295. NotFull:    and    ax, 0007h    ; get just the bottom 3 bits
  296.         mov    bx, ax
  297.         double    bx
  298.         mov    bx, CharacterTable[bx]
  299. ;────────────────────────────────────────────────────────────────────────────
  300. Stuffit:    mov    ah, BRIGHT_ON_BLACK
  301.         mov    al, bl
  302.         stosw
  303.         mov    al, bh
  304.         stosw
  305.         loop    CvrtOneBlock
  306. ;────────────────────────────────────────────────────────────────────────────
  307.         add    di, (80-6)*2        ; drop to next line
  308.         pop    cx
  309.         loop    CvrtOneLine
  310. ;────────────────────────────────────────────────────────────────────────────
  311.         add    di, 160            ; skip one line
  312.         pop    cx
  313.         loop    CvrtOneLevel
  314. ;────────────────────────────────────────────────────────────────────────────
  315.         pop    es
  316.         pop    bx
  317.         ret
  318.  
  319.  
  320. ShowNumerics:
  321. ;╒══════════════════════════════════════════════════════════════════════════╕
  322. ;│            Show the current piece and the total number of moves        │
  323. ;└──────────────────────────────────────────────────────────────────────────┘
  324.         push    bx
  325.         push    dx
  326.         push    bp
  327.         push    es
  328.         mov    es, ScreenSegment
  329.         mov    ax, CurrentTreePosition[bx]    ; get current pos
  330.         inc    ax
  331.         mov    di, NumericsPosition[bx]
  332.         cmp    ax, 10
  333.         jae    DoTheNumber
  334.         mov    BYTE PTR es:[di-2], " "    ; less than 10, so blank 10's place
  335. DoTheNumber:    call    DoNumeric
  336.  
  337.  
  338. ;────────────────────────────────────────────────────────────────────────────
  339. ;             Now update the total move display
  340. ;────────────────────────────────────────────────────────────────────────────
  341.         mov    ax, Count2
  342.         mov    bx, Count1
  343.         mov    di, (19*80+78)*2
  344.         call    PlaceLargeNumb
  345. ;────────────────────────────────────────────────────────────────────────────
  346.         mov    ax, TickCount2
  347.         mov    bx, TickCount1
  348.         mov    di, (20*80+78)*2
  349.         call    PlaceLargeNumb
  350. ;────────────────────────────────────────────────────────────────────────────
  351.         pop    es
  352.         pop    bp
  353.         pop    dx
  354.         pop    bx
  355. JustReturn:    ret
  356.  
  357.  
  358. PlaceLargeNumb:    
  359. ;╒══════════════════════════════════════════════════════════════════════════╕
  360. ;│                          At [di] place ax,bx                    │
  361. ;└──────────────────────────────────────────────────────────────────────────┘
  362.         mov    cx, 10        ; divisor
  363.         mov    bp, 1
  364. ;────────────────────────────────────────────────────────────────────────────
  365. DoAnotherDig:    zero    dx        ; clear the high side
  366.         div    cx        ; divide high half by ten
  367.         xchg    ax, bx
  368.         div    cx
  369.         xchg    ax, bx
  370.         add    dl, "0"        ; turn it into ASCII
  371. PlaceChar:    mov    es:[di], dl    ; stuff an ascii digit
  372.         sub    di, 2        ; back up 1 byte to the left
  373.         mov    dx, ax        ; are we all done ?
  374.         or    dx, bx
  375.         jz    JustReturn
  376. ;────────────────────────────────────────────────────────────────────────────
  377. CheckComma:    inc    bp
  378.         cmp    bp, 4
  379.         jb    DoAnotherDig
  380.         mov    dl, ","
  381.         zero    bp
  382.         jmp    PlaceChar
  383.  
  384.  
  385.  
  386. ShowImageCount:
  387. ;╒══════════════════════════════════════════════════════════════════════════╕
  388. ;│       Show the number of images for the current piece ...            │
  389. ;└──────────────────────────────────────────────────────────────────────────┘
  390.         mov    ax, PieceImageCounts[bx]    ; get the count
  391.         mov    di, NumericsPosition[bx]
  392.         mov    es, ScreenSegment
  393.         call    DoNumeric
  394.         pupop    es, cs
  395.         ret
  396.  
  397. DoNumeric:    
  398. ;╒══════════════════════════════════════════════════════════════════════════╕
  399. ;│       Convert the value of AX into on On-Screen number ...            │
  400. ;└──────────────────────────────────────────────────────────────────────────┘
  401.         mov    cx, 10        ; divisor
  402. DoADigit:    zero    dx        ; clear the high side
  403.         div    cx
  404.         add    dl, "0"        ; turn it into ASCII
  405.         mov    es:[di], dl    ; stuff an ascii digit
  406.         sub    di, 2        ; back up 1 byte to the left
  407.         check    ax
  408.         jnz    DoADigit
  409.         ret
  410.  
  411. SaveScreenAndCursor:
  412. ;┌──────────────────────────────────────────────────────────────────────────┐
  413. ;│           Tuck the caller's screen and cursor away for safety        │
  414. ;└──────────────────────────────────────────────────────────────────────────┘
  415.         mov    cx, SCREEN_LENGTH / 2        ; save initial screen
  416.         zero    si
  417.         mov    di, OFFSET InitScreenBuffer
  418.         mov    ds, ScreenSegment
  419.         rep movsw
  420.         pupop    ds, cs
  421. ;────────────────────────────────────────────────────────────────────────────
  422.         mov    ax, GET_CURSOR_POS*256    ; save prior cursor pos
  423.         zero    bh
  424.         int    VIDEO_IO
  425.         mov    InvocationCursor, dx
  426. ;────────────────────────────────────────────────────────────────────────────
  427.         mov    ax, SET_CURSOR_POS*256    ; and remove the cursor
  428.         zero    bh            ; (screen page 0)
  429.         mov    dx, 25*256+0        ; line 26, column 0
  430.         int    VIDEO_IO
  431.         ret
  432.  
  433. AllocateMemoryRegions:
  434. ;┌──────────────────────────────────────────────────────────────────────────┐
  435. ;│       Free up the system's RAM, then make the following regions:        │
  436. ;│       64K - for the piece positions.                        │
  437. ;└──────────────────────────────────────────────────────────────────────────┘
  438.         mov    ah, DOS_SETBLOCK
  439.         mov    bx, (TopOfStack-StartOfProg+15)/16
  440.         pupop    es, cs
  441.         int    DOS_FUNC        ; reduce our allocation
  442.         ret
  443.  
  444. CountTicks:
  445. ;┌──────────────────────────────────────────────────────────────────────────┐
  446. ;│             Accumulate the total number of ticks accumulated            │
  447. ;└──────────────────────────────────────────────────────────────────────────┘
  448.         pushf
  449.         bool    cs:SingleStepping
  450.         iftrue    TickCounted
  451.         inc    cs:TickCount1
  452.         jnz    TickCounted
  453.         inc    cs:TickCount2
  454. TickCounted:    popf
  455.         jmp    cs:[OldTimerVector]  ; and proceed to Original Int8
  456.  
  457.  
  458. OperatorCheck:
  459. ;┌──────────────────────────────────────────────────────────────────────────┐
  460. ;│           Accumulate the total number of tests performed ...            │
  461. ;└──────────────────────────────────────────────────────────────────────────┘
  462.         bool    Sound
  463.         iffalse    IncCount
  464.         call    ToggleSpeaker
  465. IncCount:    inc    Count1
  466.         jnz    Accumed
  467.         inc    Count2
  468. ;────────────────────────────────────────────────────────────────────────────
  469. Accumed:    cmp    bx, 8*2
  470.         jne    NotDone
  471.         call    AttentionSound
  472.         call    AttentionSound
  473.         jmp    SetPause
  474.  
  475. ;────────────────────────────────────────────────────────────────────────────
  476. NotDone:    cmp    bx, PausePoint
  477.         je    SetPause
  478.  
  479. ;────────────────────────────────────────────────────────────────────────────
  480. CheckStep:    bool    SingleStepping
  481.         iftrue    Pause
  482.         mov    ah, GETKEY_NOWAIT
  483.         int    KEYBOARD_IO
  484.         jnz    Pause
  485.         ret
  486.  
  487. ;════════════════════════════════════════════════════════════════════════════
  488. SetPause:    set    SingleStepping
  489.         call    AttentionSound
  490. Pause:        call    ShowAllPieces
  491.         call    WaitForKeyPress
  492.         call    KeystrokeSound
  493. ;────────────────────────────────────────────────────────────────────────────
  494. CheckPress:    cmp    al, ESC_
  495.         je    Exit
  496.         cmp    al, " "
  497.         jne    NotSpace
  498.         set    SingleStepping
  499.         ret
  500.  
  501. ;────────────────────────────────────────────────────────────────────────────
  502. NotSpace:    cmp    al, CR
  503.         jne    NotCR
  504.         xor    SingleStepping, 0FFh
  505.         jnz    CheckStep
  506.         call    WaitForClockTick
  507.         jmp    CheckStep
  508.  
  509.  
  510. ;────────────────────────────────────────────────────────────────────────────
  511. NotCR:        cmp    al, "9"
  512.         ja    NotNumeric
  513.         cmp    al, "0"
  514.         jb    NotNumeric
  515.         sub    al, "1"        ; al = 0 to 8
  516.         double    al
  517.         mov    BYTE PTR PausePoint, al
  518.         jmp    RefreshUs
  519.  
  520. ;────────────────────────────────────────────────────────────────────────────
  521. NotNumeric:    cmp    al, "a"
  522.         jae    CheckAscii
  523.         add    al, "a"-"A"
  524. ;────────────────────────────────────────────────────────────────────────────
  525. CheckAscii:    cmp    al, "a"
  526.         jne    SoundOnOff
  527.         xor    Animation, 0FFh
  528. RefreshUs:    call    RefreshScreen
  529.         jmp    CheckStep
  530. ;────────────────────────────────────────────────────────────────────────────
  531. SoundOnOff:    cmp    al, "s"
  532.         jne    Update
  533.         xor    Sound, 0FFh
  534.         jmp    RefreshUs
  535. ;────────────────────────────────────────────────────────────────────────────
  536. Update:        cmp    al, "u"
  537.         jne    CheckStep
  538.         Call    ShowAllPieces
  539.         jmp    RefreshUs
  540.  
  541.  
  542. RefreshScreen:
  543. ;┌──────────────────────────────────────────────────────────────────────────┐
  544. ;│  Shows the current state of the Animation, Sound, and Partial booleans   │
  545. ;└──────────────────────────────────────────────────────────────────────────┘
  546.         mov    es, ScreenSegment
  547.         bool    Animation
  548.         mov    di, (23*80+3)*2+1
  549.         call    RefreshOne
  550. ;────────────────────────────────────────────────────────────────────────────
  551.         bool    Sound
  552.         mov    di, (21*80+34)*2+1
  553.         call    RefreshOne
  554. ;────────────────────────────────────────────────────────────────────────────
  555.         mov    al, BYTE PTR PausePoint
  556.         halve    al            ; 0-9
  557.         add    al, "1"            ; "0" - "9"
  558.         cmp    al, 0B0h
  559.         jne    ShowPause
  560.         mov    al, "-"
  561. ShowPause:    mov    di, (23*80+57)*2
  562.         mov    es, ScreenSegment
  563.         stosb
  564.         pupop    es, cs
  565.         ret
  566.  
  567.  
  568. ;────────────────────────────────────────────────────────────────────────────
  569. RefreshOne:    mov    cx, 25
  570.         mov    al, BRIGHT_ON_MAGENTA
  571.         mov    si, OFFSET ONStatus
  572.         iftrue    RefreshIt
  573.         mov    al, DIM_ON_MAGENTA
  574.         mov    si, OFFSET OFFStatus
  575. RefreshIt:    stosb
  576.         inc    di
  577.         loop    RefreshIt
  578.         sub    di, 7
  579.         mov    cx, 3
  580. RefreshWord:    movsb
  581.         inc    di
  582.         loop    RefreshWord
  583.         ret    
  584.  
  585. ;╒══════════════════════════════════════════════════════════════════════════╕
  586. ;│                         Sound Generation Sub-System                │
  587. ;╘══════════════════════════════════════════════════════════════════════════╛
  588. KeystrokeSound:    mov    Period, 500        ; typing thunk sound
  589.         mov    Duration, 18
  590.         jmp    ToneBurst
  591.  
  592. ;────────────────────────────────────────────────────────────────────────────
  593. AttentionSound:    mov    Period, 1500        ; first period
  594.         mov    DeltaFreq, 35        ; period change each half-cyc
  595.         mov    Duration,  40        ; half-cycle count
  596.         jmp    ToneSlide
  597.  
  598. ;╒══════════════════════════════════════════════════════════════════════════╕
  599. ;│    Enter with "Period", "Duration" and "DeltaFreq" all set as needed...  │
  600. ;└──────────────────────────────────────────────────────────────────────────┘
  601. ToneBurst:    mov    DeltaFreq, 0
  602. ToneSlide:      pushf
  603.         push    ax
  604.         cli
  605.         Call    GetPhasorPos    ; set initial angle
  606.         mov    PhasorPosition, ax
  607.  
  608. NextCycle:    mov    ax, Period    ; update the phasor angle
  609.         sub    PhasorPosition, ax
  610.  
  611. GetCycleEnd:    Call    GetPhasorPos
  612.         sub    ax, PhasorPosition
  613.         abs_    ax
  614.         cmp    ax, 100
  615.         jae    GetCycleEnd
  616.  
  617.         Call    ToggleSpeaker
  618.         mov    ax, DeltaFreq
  619.         sub    Period, ax
  620.         dec    Duration
  621.         jnz    NextCycle
  622.         sti
  623.         pop    ax
  624. ToneMade:    popf
  625.         ret
  626.  
  627.  
  628. ;════════════════════════════════════════════════════════════════════════════
  629. GetPhasorPos:    mov    al, 00000100B    ; latch timer_0
  630.         outt    TIMER_MODE, al
  631.         inn    al, TIMER_0    ; LSB
  632.         xchg    ah, al
  633.         inn    al, TIMER_0    ; MSB
  634.         xchg    ah, al        ; finally form the count
  635.         ret
  636.         
  637. ;════════════════════════════════════════════════════════════════════════════
  638. ToggleSpeaker:    inn    al, SPEAKER_GATE
  639.         and    al, NOT OSCILLATOR_GATE_BIT    ; kill OSC Input
  640.         xor    al, SPEAKER_DATA_BIT        ; invert Spkr Data
  641.         outt    SPEAKER_GATE, al
  642.         ret
  643.  
  644.  
  645. WaitForClockTick:
  646. ;╒══════════════════════════════════════════════════════════════════════════╕
  647. ;│                     Wait for a Timer Tick to occur                │
  648. ;└──────────────────────────────────────────────────────────────────────────┘
  649.         sti
  650.         mov    ax, TickCount1
  651. KeepWaiting:    cmp    ax, TickCount1
  652.         je    KeepWaiting
  653.         ret
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664. ScreenDisplay:
  665. ;────────────────────────────────────────────────────────────────────────────
  666. db " ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ "
  667. db "   Heuristic Combinatorial Cube Solver  (c) 1990, Gibson Research Corporation   "
  668. db " ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ "
  669. db "      ┌──────┬──────┬──────┬── Pieces ───┬──────┬──────┬──────┐        Result   "
  670. db "      1      2      3      4      5      6      7      8      9         Cube    "
  671. db " █▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█  █▀▀▀▀▀▀▀▀█ "
  672. db " █                                                                █  █        █ "
  673. db " █                                                                █  █        █ "
  674. db " █                                                                █  █        █ "
  675. db " █                                                                █  █        █ "
  676. db " █                                                                █  █        █ "
  677. db " █                                                                █  █        █ "
  678. db " █                                                                █  █        █ "
  679. db " █                                                                █  █        █ "
  680. db " █                                                                █  █        █ "
  681. db " █                                                                █  █        █ "
  682. db " █                                                                █  █        █ "
  683. db " █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█  █▄▄▄▄▄▄▄▄█ "
  684. db "                                                                                "
  685. db "      └──────┴──────┴──────┴─ Position ──┴──────┴──────┴──────┘  Moves:         "
  686. db " ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄  ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄      Time:         "
  687. db "   [ENTER] to Start / Stop        [S] Sound Monitor           ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄ "
  688. db "   [SPACEBAR] to Stop / Step      [U] Update Positions          Press the ESC   "
  689. db "   [A] Animate Screen             [0-9] Pause at piece  - -      key to Exit.   "
  690. db " ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀  ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀  ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ "
  691.  
  692. NormalTermination:
  693. ;────────────────────────────────────────────────────────────────────────────
  694. db CR,LF
  695. db "                       █▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█",CR,LF
  696. db "                       █   Cubit terminated normally.  █",CR,LF
  697. db "                       █▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█",CR,LF,"$"
  698. ;────────────────────────────────────────────────────────────────────────────
  699. ONStatus:    db    "ON "
  700. OFFStatus:    db    "OFF"
  701.  
  702. ;┌──────────────────────────────────────────────────────────────────────────┐
  703. ;│                   End of the CUBESYS.INC include file            │
  704. ;└──────────────────────────────────────────────────────────────────────────┘
  705.  
  706.